import BaseAction from "./BaseAction";
import GlobalEvent from "../../../cfw/event/GlobalEvent";
import { EventName, FaceType } from "../../../public/Config";



export default class EatingAction extends BaseAction {



    start() {
        cc.tween(this).repeat(5,
            cc.tween(this).to(0.2, {}).call(this.open.bind(this)).to(0.2, {}).call(this.close.bind(this))
        ).call(this.finish.bind(this)).start()
    }

    open() {
        GlobalEvent.instance().emit(EventName.CHANGE_FACE_TYPE, FaceType.EATTING)
    }

    close() {
        GlobalEvent.instance().emit(EventName.CHANGE_FACE_TYPE, FaceType.OPEN_SMILE)
    }

    finish() {
        GlobalEvent.instance().emit(EventName.CHANGE_FACE_TYPE, FaceType.SMILE)
        GlobalEvent.instance().emit(EventName.EATING_FINISH)
    }

}
